package cn.stylefeng.guns.sys.modular.upload.servie.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.sys.modular.upload.entity.FileTable;
import cn.stylefeng.guns.sys.modular.upload.mapper.UploadMapper;
import cn.stylefeng.guns.sys.modular.upload.servie.UploadService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UploadServiceImpl implements UploadService {
    @Autowired
    UploadMapper uploadMapper;

    @Override
    public void uploadFile(String nowTime, String uuid, String fileType, String s, String userId, String remark, String fileName, String messageId) {
        uploadMapper.insertFile(nowTime, uuid, fileType, s, userId, remark, fileName, messageId);
    }

    @Override
    public IPage<Map<String, Object>> selectByList(String messageId) {
        Page pageContext = getPageContext();
        IPage<Map<String, Object>> list = uploadMapper.selectByList(pageContext, messageId);
        return list;
    }

    @Override
    public List<FileTable> queryFileTable(Integer userId, Integer messageId) {
        return uploadMapper.list(userId, messageId);
    }

    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }
}
